package com.maila.xiaoaoschool.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.maila.xiaoaoschool.R;
import com.maila.xiaoaoschool.activity.ShopDetailsActivity;
import com.maila.xiaoaoschool.util.StartActivityUtils;
import com.zhy.autolayout.AutoLinearLayout;
import com.zhy.autolayout.utils.AutoUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 折扣优惠商品
 * Created by Administrator on 2017/9/26.
 */

public class SaleFoodAdapter extends BaseAdapter {
    Context context;

    public SaleFoodAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return 6;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.item_sale, viewGroup, false);
            holder = new ViewHolder(view);
            view.setTag(holder);
            AutoUtils.autoSize(view);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                StartActivityUtils.start(context, ShopDetailsActivity.class);
            }
        });
        return view;
    }


    static class ViewHolder {
        @BindView(R.id.iv_shop)
        ImageView ivShop;
        @BindView(R.id.tv_shop_name)
        TextView tvShopName;
        @BindView(R.id.tv_xiaoliang)
        TextView tvXiaoliang;
        @BindView(R.id.tv_fee)
        TextView tvFee;
        @BindView(R.id.tv_manjian)
        TextView tvManjian;
        @BindView(R.id.ll_manjian)
        AutoLinearLayout llManjian;
        @BindView(R.id.tv_shoudan)
        TextView tvShoudan;
        @BindView(R.id.ll_shoudan)
        AutoLinearLayout llShoudan;
        @BindView(R.id.tv_zhekou)
        TextView tvZhekou;
        @BindView(R.id.ll_zhekou)
        AutoLinearLayout llZhekou;
        @BindView(R.id.tv_tejia)
        TextView tvTejia;
        @BindView(R.id.ll_tejia)
        AutoLinearLayout llTejia;
        @BindView(R.id.tv_fanquan)
        TextView tvFanquan;
        @BindView(R.id.ll_fanquan)
        AutoLinearLayout llFanquan;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
